package com.oocl.o2o.merchant.controller.rest;

import java.util.Date;
import java.util.List;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.SessionAttribute;

import com.oocl.o2o.merchant.entity.Commentary;
import com.oocl.o2o.merchant.entity.Merchant;
import com.oocl.o2o.merchant.service.CommentaryManager;

@RestController
@RequestMapping("/sec/rest/commentary")
public class CommentaryController {
	@Autowired
	private CommentaryManager commentaryManager;

	@GetMapping
	public List<Commentary> getCommentaries(@SessionAttribute String merchantId) {
		return commentaryManager.findByMerchantId(merchantId);
	}

	@GetMapping("/{commentaryId}/{merchantCommentary}")
	public Commentary replyCommentary(@PathVariable("commentaryId")String commentaryId, 
			@PathVariable("merchantCommentary")String merchantCommentary) {
		return commentaryManager.reply(commentaryId, merchantCommentary, new Date());
	}
}
